//
//  CourseVideoViewMenuMini.m
//  xpkc
//
//  Created by TopSage on 15/10/23.
//  Copyright (c) 2015年 TopSage. All rights reserved.
//

#import "CourseVideoViewMenuMini.h"

@interface CourseVideoViewMenuMini (){
    UIView *topview;
    UIView *bottomview;
}

@end

@implementation CourseVideoViewMenuMini

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatView];
    }
    return self;
}

- (void)creatView{
    
    CGRect frame_top;
    CGRect frame_bottom;
    CGRect frame_btn_back;
    CGRect frame_label_title;
    CGRect frame_btn_down;
    CGRect frame_btn_play;
    CGRect frame_btn_full;
    CGRect frame_progress;
    
    frame_top           = CGRectMake(0, 0, SCREEN_WIDTH, 58);
    frame_btn_back      = CGRectMake(0, 20, 38, 38);
    frame_label_title   = CGRectMake(40, 20, SCREEN_WIDTH-100, 38);
    frame_btn_down      = CGRectMake(SCREEN_WIDTH-60, 20, 50, 28);
    frame_bottom        = CGRectMake(0, self.frame.size.height-40, SCREEN_WIDTH, 40);
    frame_btn_play      = CGRectMake(10, 0, 40, 40);
    frame_progress      = CGRectMake(5, 0, SCREEN_WIDTH-10, 2);
    frame_btn_full      = CGRectMake(SCREEN_WIDTH - 60, 6, 50, 28);
    
    //top
    topview = [[UIView alloc]initWithFrame:frame_top];
    topview.backgroundColor = [UIColor colorWithRed:0.4 green:0.4 blue:0.4 alpha:0.3];
    [self addSubview:topview];
    
    self.backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.backBtn setImage:[UIImage imageNamed:@"back1"] forState:UIControlStateNormal];
    self.backBtn.frame = frame_btn_back;
    [topview addSubview:self.backBtn];
    
    self.titleLabel = [[UILabel alloc]initWithFrame:frame_label_title];
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    self.titleLabel.text = @"课程标题";
    [topview addSubview:self.titleLabel];
    
    self.downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.downBtn setTitle:@"下载" forState:UIControlStateNormal];
    self.downBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    self.downBtn.layer.cornerRadius = 3;
    self.downBtn.layer.borderWidth = 1;
    self.downBtn.layer.borderColor = [UIColor whiteColor].CGColor;
    self.downBtn.frame = frame_btn_down;
    [topview addSubview:self.downBtn];
    
    //bottom
    bottomview = [[UIView alloc]initWithFrame:frame_bottom];
    bottomview.backgroundColor = [UIColor colorWithRed:0.4 green:0.4 blue:0.4 alpha:0.3];
    [self addSubview:bottomview];
    
    self.playBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.playBtn setImage:[UIImage imageNamed:@"ic_play_media"] forState:UIControlStateNormal];
    [self.playBtn setImage:[UIImage imageNamed:@"ic_stop_media"] forState:UIControlStateSelected];
    self.playBtn.frame = frame_btn_play;
    [bottomview addSubview:self.playBtn];
    
    self.progress = [[UISlider alloc]initWithFrame:frame_progress];
    self.progress.minimumValue = 0;
    self.progress.maximumValue = 1;
    [bottomview addSubview:self.progress];
    
    UIImage *leftImg =
    [[UIImage imageNamed:@"leftSlider5"]stretchableImageWithLeftCapWidth:1 topCapHeight:0];
    UIImage *rightImg =
    [[UIImage imageNamed:@"rightSlider5"]stretchableImageWithLeftCapWidth:1 topCapHeight:0];
    [self.progress setMinimumTrackImage:leftImg forState:UIControlStateNormal];
    [self.progress setMaximumTrackImage:rightImg forState:UIControlStateNormal];
    if (!isPad) {
        [self.progress setThumbImage:[UIImage imageNamed:@"player_redbutton"] forState:UIControlStateNormal];
        [self.progress setThumbImage:[UIImage imageNamed:@"player_redbutton_down"] forState:UIControlStateHighlighted];
    }else{
        [self.progress setThumbImage:[UIImage imageNamed:@"player_redbutton"] forState:UIControlStateNormal];
        [self.progress setThumbImage:[UIImage imageNamed:@"player_redbutton_down"] forState:UIControlStateHighlighted];
    }
    
    self.fullBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.fullBtn setTitle:@"全屏" forState:UIControlStateNormal];
    self.fullBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    self.fullBtn.frame = frame_btn_full;
    self.fullBtn.layer.cornerRadius = 3;
    self.fullBtn.layer.borderWidth = 1;
    self.fullBtn.layer.borderColor = [UIColor whiteColor].CGColor;
    [bottomview addSubview:self.fullBtn];
}

- (void)showMenu{
    [UIView animateWithDuration:0.3 animations:^{
        topview.alpha = 1;
        bottomview.alpha = 1;
    }];
    self.isHide = NO;
}

- (void)hideMenu{
    [UIView animateWithDuration:0.3 animations:^{
        topview.alpha = 0;
        bottomview.alpha = 0;
    }];
    self.isHide = YES;
}


@end
